package DataBase;


import java.sql.PreparedStatement;
import java.sql.SQLException;




/**
 * This is the Class that makes Logout action from DB .
 * @author Evgeny
 * @author Igor
 * @author Samir
 * @author Konstantin
 *
 */
public class Logout  {

 

	/**
	 * 
	 * @param Username  The username to logout (to change the online status to 0)
	 */
	public void LogoutUserFromDB(String Username){

		try {
			SQLConnection sc = new SQLConnection();
			
			PreparedStatement ps = sc.getConnection().prepareStatement("UPDATE User SET LoginStatus=0 WHERE UserName=?");
			
			ps.setString(1, Username);
			
			ps.executeUpdate();
			
			System.out.println("User was logged out successfully");

			ps.close();

			
		} catch (SQLException e) {	e.printStackTrace();}
	}
		
	}
		
		



